#ifndef SETTINGMANAGE_H
#define SETTINGMANAGE_H

#include <QObject>
#include <QSettings>
#include <QVariant>


class SettingManage:public QObject
{
public:
    explicit SettingManage(QObject *parent = nullptr);
    ~SettingManage();

    static SettingManage* instance();// 单例模式访问

    void setValue(const QString &key, const QVariant &value);
    QVariant getValue(const QString &key, const QVariant &defaultValue = QVariant()) const;

    // 检查配置是否存在
    bool contains(const QString &key) const;

    // 删除配置项
    void remove(const QString &key);

    // 同步到磁盘
    void sync();

private:
    static SettingManage* m_instance;
    QSettings *m_pSettings;

};

#endif // SETTINGMANAGE_H
